package com.example.test_01.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.test_01.R;
import com.example.test_01.model.User;

import java.util.List;

public class UserSpinnerAdapter extends BaseAdapter {
    Context context;
    List<User> userList;

    public UserSpinnerAdapter(Context context, List<User> userList) {
        this.context = context;
        this.userList = userList;
    }

    public User getUserItem(int i){
        return userList.get(i);
    }
    @Override
    public int getCount() {
        return userList.size();
    }

    @Override
    public Object getItem(int i) {
        return userList.get(i).getNickname();
    }

    @Override
    public long getItemId(int i) {
        return userList.get(i).getId();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = LayoutInflater.from(context).inflate(R.layout.spinner_item,null);
        TextView textView = view.findViewById(R.id.tv_spinner_item);
        textView.setText(userList.get(i).getNickname());
        return view;
    }
}
